package com.demo.common;

import com.jfinal.kit.JMap;
import com.jfinal.kit.StrKit;
import com.jfinal.template.Engine;
import com.jfinal.template.Template;

/**
 * Created by jie on 2017/3/2.
 */
public class EngineKit {
    private static Engine engine = null;

    static {
        engine = Engine.create("db");
        engine.addSharedMethod(new RandomKit());
    }

    public static String getDbName(RoutDb routDb) {
        String expr = routDb.expr();
        String value = routDb.value();
        int size = routDb.size();
        Template template = engine.getTemplateByString(expr);
        JMap map = new JMap();
        map.put("dsName", value);
        map.put("size", size);
        return template.renderToString(map);
    }
}
